package com.lsx.controller;

import com.lsx.entity.Account;
import com.lsx.entity.Wallet;
import com.lsx.service.AppShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/appshop")
public class AppShopController {

    @Autowired
    private AppShopService appShopService;

    /**
     * 查询钱包余额
     * @param wid
     * @param model
     * @return
     */
    @RequestMapping("/queryRamaining")
    public String queruRamaining(@RequestParam("wid") Integer wid, Model model){
        Wallet wallet = appShopService.queruRamaining(wid);
        model.addAttribute("wallet",wallet);
        return "test";
    }

    /**
     * 消费100元
     * @param wid
     * @return
     */
    @RequestMapping("/consume100")
    public String consume100(@RequestParam("wid") Integer wid){
        appShopService.consume100(wid);
        return "test";
    }

    /**
     * 退款20元
     * @param wid
     * @return
     */
    @RequestMapping("/refund20")
    public String refund20(@RequestParam("wid") Integer wid){
        appShopService.refund20(wid);
        return "test";
    }

    /**
     * 查询钱包金额明细
     * @param wid
     * @param model
     * @return
     */
    @RequestMapping("/accountDetails")
    public String accountDetails(@RequestParam("wid") Integer wid, Model model){
        Account account = appShopService.accountDetails(wid);
        model.addAttribute("account",account);
        return "test";
    }

}
